<?php
session_start();
include '../../include/dbFunctions.php';

if (isset($_SESSION['volunteer_id'])) {

    $volunteer_id = $_SESSION['volunteer_id'];
$valid = "true";

$email = trim(strtolower($_REQUEST['volunteer_email']));

$query = executeSelectQuery("SELECT volunteer_email FROM volunteer WHERE volunteer_email = '" . $email . "' AND volunteer_id <> $volunteer_id;");
if (count($query) > 0) {
    $valid = "false"; //Email is existed, cannot use
}
echo $valid;
}


/* For Debugging
  $query = "SELECT * FROM username WHERE email = '" . $email . "';";
  foreach ($dbh->query($query) as $row) {
  echo $row['email'] . "<br/>";
  }
 */
?>
